package com.yuanfeng.base.controller;

import com.yuanfeng.commoms.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @ClassName BaseDistrictController
 * @Description 地区
 * @Author hyq
 * @Date 2023/6/19 16:14
 * @Version 1.0
 **/
@CrossOrigin
@RestController
@RequestMapping("/base/district")
public class BaseDistrictController extends BaseController {


    /**
     * 根据父id查询省市区
     *
     * @param districtParentId
     * @return
     */
    @GetMapping("/query")
    public ResponseResult queryDistinct(Integer districtParentId) {

        return baseDistrictService.queryDistinct(districtParentId);
    }

    /**
     * 查询地区 feign
     * @param provinceId
     * @return
     */
    @PostMapping("/queryProvinceport")
    public String queryProvinceport(@RequestParam("provinceId")String provinceId){
        return baseDistrictService.queryProvinceport(provinceId);
    }


    /**
     * 得到地址信息
     *
     * @param provinceId
     * @param cityId
     * @param districtId
     * @return
     */
    @GetMapping("/getAddressString")
    public ResponseResult getAddressString(@RequestParam("province") Integer provinceId,
                                   @RequestParam("city") Integer cityId,
                                   @RequestParam("county") Integer districtId) {
        ResponseResult address = baseDistrictService.getAddressString(provinceId, cityId, districtId);

        return address;
    }

    /**
     * 查询所有的省市区
     * @return
     */
    @PostMapping("/queryAll")
    public ResponseResult queryAllDistrict() {
        return baseDistrictService.queryAllDistrict();
    }


    /**
     * 查询地区名称 feign
     * @return
     */
    @PostMapping(value = "/query/district/name")
    public List<String> queryDistrictName(@RequestBody List<Integer> districtIds) {
        return baseDistrictService.selectByIdList(districtIds);
    }
    /**
     * 查询地区表所对应的名称
     *
     * @param districtMap
     * @return
     */
    @PostMapping("/queryRegionName")
    public List<String> queryRegionName(@RequestBody Map<String, Integer> districtMap) {
        return baseDistrictService.queryRegionName(districtMap);
    }
}
